package com.mpp.admin.entity;

import lombok.Data;

/**
 * @DES 操作结果返回值
 * @author mapp
 */
@Data
public class Result {

    private static final String DEFALUT_SUCCESS_MSG = "保存成功";
    private static final String DEFALUT_SUCCESS_CODE = "200";
    private static final String DEFALUT_FAIL_MSG = "保存失败";
    private static final String DEFALUT_FAIL_CODE = "500";

    /** 成功或者失败 */
    private boolean success;
    /** 状态码 */
    private String statusCode;
    /** 消息 */
    private String message;
    /** 返回数据 */
    private Object data;

    public Result(boolean success, String statusCode, String message) {
        this.success = success;
        this.statusCode = statusCode;
        this.message = message;
    }


    public Result(boolean success, String statusCode, String message, Object data) {
        this(success, statusCode, message);
        this.data = data;
    }

    public static Result getSuccessResult() {
        return new Result(true, DEFALUT_SUCCESS_CODE, DEFALUT_SUCCESS_MSG);
    }

    public static Result getSuccessResult(Object data) {
        return new Result(true, DEFALUT_SUCCESS_CODE, DEFALUT_SUCCESS_MSG, data);
    }

    public static Result getSuccessResult(String message) {
        return new Result(true, DEFALUT_SUCCESS_CODE, message);
    }

    public static Result getSuccessResult(String message, Object data) {
        return new Result(true, DEFALUT_SUCCESS_CODE, message, data);
    }

    public static Result getFailResult(String message) {
        return new Result(false, DEFALUT_FAIL_CODE, message);
    }

    public static Result getFailResult(Object data) {
        return new Result(false, DEFALUT_FAIL_CODE, DEFALUT_FAIL_MSG, data);
    }

    public static Result getFailResult() {
        return new Result(false, DEFALUT_FAIL_CODE,  DEFALUT_FAIL_MSG);
    }

    public static Result getFailResult(String message, Object data) {
        return new Result(false, DEFALUT_FAIL_CODE, message, data);
    }

}
